<template>
  <div class="goods-item" @click="itemClick">
    <img :src="product.cover_url" alt="" />
    <div class="goods-info">
      <p>{{product.title}}</p>
      <span class="price">￥{{product.price}}</span>
      <span class="collect">{{product.collects_count}}</span>
    </div>
  </div>
</template>

<script>
import {useRouter} from 'vue-router';
export default {
  name: "GoodsListItem",
  setup(props) {
    const router = useRouter();

    return {
      itemClick:() => {
        router.push({
          path: 'detail',
          query: {
            id: props.product.id,
          }
        })
      }
    }
  },
  props: {
    product: {
      typs: Object,
      defalut() {
        return {}
      }
    }
  }
};
</script>

<style scoped lang="scss">
.goods-item {
  width: 45%;
  padding-bottom: 40px;
  position: relative;
  z-index: 5;

  img {
    width: 100%;
    border-radius: 5%;
  }

  .goods-info {
    font-size: 15px;
    position: absolute;
    bottom: 5px;
    left: 0;
    right: 0;
    overflow: hidden;
    p {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      margin-top: 3px;
      margin-bottom: 5px;
    }

    .price {
      color: red;
      margin-right: 40px;
    }
    .collect {
      position: relative;
      color: orange;
    }
    .collect::before {
      content: '';
      width: 14px;
      height: 14px;
      background: url('~assets/image/shoucang.png') 0 0 / 14px 14px;
      position: absolute;
      left: -18px;
      top: 3px;
    }
  }
}
</style>
